@echo off

set /p ifBuid=If need to buid this project[0/1]: 
set devpath=C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE
rem path %path%;%devpath%

if "%ifBuid%" == "1" (
	@echo [32mBuilding the project...[0m
	set VCINSTALLDIR_CMD="C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat"
	call %VCINSTALLDIR_CMD%
	"%devpath%\devenv" ./PowerScope.sln /Build "Release|AnyCPU"
	rem pause
)

@echo [32mCopy the app...[0m
set src=%cd%\bin\Release\net461\
set release=%cd%\release\PowerScope\
xcopy /y %src% %release% /E /EXCLUDE:.\exclude.txt

@echo [32mConfusing the app...[0m
call "confuser\Confuser.CLI.exe" -n confuser\PowerScope.crproj
if %errorlevel% NEQ 0 (
	@echo [31mConfusing Error![0m
	pause
	exit
)

@echo [32mPacking the app...[0m
cd release
rem set name=%~n0
set achive=%cd%\PowerScope.zip
"..\apps\7z\7z.exe" a "%achive%" "%cd%\PowerScope\"
if %errorlevel% NEQ 0 (
	@echo [31mPacking Error![0m
	pause
	exit
)

rd /s /q %release%
@echo [32mFinished![0m
pause